package hyl.core.conf;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.alibaba.fastjson.JSON;

/**
 * 
 * @ClassName: Zdy
 * @Description: 自定义属性 所有的
 * @author zoudy
 * @date 2018年2月8日 下午6:33:13
 * @version V1.0
 */
public class ACCMap {
	protected Map<String, Object> props = new ConcurrentHashMap<String, Object>();

	public void put(String key, Object value) {
		props.put(key, value);
	}

	public Object remove(String key) {
		return props.remove(key);
	}

	public Object get(String key) {
		return props.get(key);
	}

	public Map<String, Object> getAll() {
		return props;
	}

	public String toJson() {
		return JSON.toJSONString(props);
	}

	public String toString() {
		return JSON.toJSONString(props);
	}

	public synchronized void load(Map<String, Object> pp) {
		this.props = pp;
	}

	@SuppressWarnings("unchecked")
	public synchronized void load(String propstring) {
		this.props = (Map<String, Object>) JSON.parseObject(propstring, Map.class);
	}

	@SuppressWarnings("unchecked")
	public static ACCMap getInstance(String props) {
		Map<String, Object> pp = (Map<String, Object>) JSON.parseObject(props, Map.class);
		ACCMap zdy = new ACCMap();
		zdy.load(pp);
		return zdy;
	}
}
